<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../session.jsp"%>
<!DOCTYPE html>
<html lang="ko">
  <head>
  	<%@ include file="../head.jsp"%>
  </head>
  <body>
  	<%@ include file="../menu.jsp"%>
	<div class="container">
		<div class="page-header">
			<h2>신규 관리자 추가 - <small>새로운 계정을 추가하세요.</small></h2>
		</div>

		<form id="insertAdmin" class="form-horizontal" role="form" method="post" action="listAdmin.do">
			<fieldset>
				<div class="form-group">
					<label for="nickName" class="col-md-2 control-label">이름</label>
					<div class="col-md-10">
						<input type="text" class="form-control" name="nickName" placeholder="이름을 입력하세요" autofocus/>
					</div>
				</div>

				<div class="form-group">
					<label for="eMail" class="col-md-2 control-label">이메일</label>
					<div class="col-md-10">
						<input type="text" class="form-control" name="eMail" placeholder="이메일 주소를 입력하세요"/>
					</div>
				</div>
				
				<div class="form-group">
					<label for="passWord1" class="col-md-2 control-label">비밀번호</label>
					<div class="col-md-10">
						<input type="password" class="form-control" name="passWord1" placeholder="비밀번호를 입력하세요"/>
					</div>
				</div>
				
				<div class="form-group">
					<label for="passWord2" class="col-md-2 control-label">비밀번호 확인</label>
					<div class="col-md-10">
						<input type="password" class="form-control" name="passWord2" placeholder="비밀번호를 한번더 입력하세요"/>
					</div>
				</div>

				<div class="form-group">
					<label for="grade" class="col-md-2 control-label">등급</label>
					<div class="col-md-10">
						<select name="grade" class="form-control">
							<option>- 선택하세요 -</option>
							<option value="1">최고관리자</option>
							<option value="2">컨텐츠관리자</option>
						</select>
					</div>
				</div>

				<div class="form-group">
					<div class="col-md-offset-2 col-md-10">
						<div class="row">
							<div class="col-md-6">
								<button type="submit" class="btn btn-primary btn-block">저장하기</button>
							</div>
							<div class="col-md-6">
								<button type="reset" class="btn btn-warning btn-block">다시작성</button>
							</div>
						</div>

					</div>
				</div>
			</fieldset>
		</form>
	</div>
	<!-- Javascript -->
	<script src="assets/js/jquery.js"></script>
	<script src="assets/js/bootstrap.min.js"></script>
	<!-- 형식검사 클래스 참조 -->
	<script src="assets/js/string.js"></script>
	<script type="text/javascript">
		$(function() {
			$("#insertAdmin").submit(function() {
				
				if (!$("input[name='nickName']").val().isValue()) {
					alert("이름을 입력하세요.");
					$("input[name='nickName']").focus();
					return false;
				}
				
				if (!$("input[name='eMail']").val().isValue()) {
					alert("이메일주소를 입력하세요.");
					$("input[name='eMail']").focus();
					return false;
				}
				
				if (!$("input[name='eMail']").val().isEmail()) {
					alert("이메일주소 형식으로만 입력이 가능합니다.");
					$("input[name='eMail']").focus();
					return false;
				}
				
				if (!$("input[name='passWord1']").val().isValue()) {
					alert("비밀번호를 입력하세요.");
					$("input[name='passWord1']").focus();
					return false;
				}
				
				if (!$("input[name='passWord2']").val().isValue()) {
					alert("비밀번호 확인을 입력하세요.");
					$("input[name='passWord2']").focus();
					return false;
				}
				
				if ($("input[name='passWord1']").val() != $("input[name='passWord2']").val()) {
					alert("비밀번호는 동일하게 입력해야 합니다.");
					$("input[name='passWord2']").focus();
					return false;
				}
				
				if ($("select[name='grade'] > option:selected").index() < 1) {
					alert("등급을 선택하세요.");
					$("select[name='grade']").focus();
					return false;
				}
				
				if (!confirm("정말 등록 하시겠습니까?")) {
					return false;
				}
			});
		});
	</script>
  </body>
</html>